//
// Created by francklinson on 2021/12/4 AT 10:23.
// May Saint Diana bless you!
//

#include <iostream>
#include <string>

using namespace std;

class Solution {
public:
    string makeFancyString(string s) {
        int sameCounter = 1;
        string ans;
        ans.push_back(s[0]);
        for (int i = 1; i < s.size(); ++i) {
            if (s[i] == s[i - 1]) {
                ++sameCounter;
            } else{
                sameCounter = 1;
            }
            if (sameCounter < 3) {
                ans.push_back(s[i]);
            }
        }
        return ans;
    }
};

int main() {
    Solution solution;
    cout << solution.makeFancyString("leeetcode") << endl;
    cout << solution.makeFancyString("aaabaaaa") << endl;
    cout << solution.makeFancyString( "aab") << endl;
    return 0;
}

